package com.sg.servlet;

import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.alibaba.fastjson.support.spring.annotation.ResponseJSONP;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sg.dao.Dao;
import com.sg.dao.IDao;
import com.sg.domain.Count;

@WebServlet("/loginServlet")
public class LoginServlet extends HttpServlet {

	protected void doGet(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		response.setContentType("text/html;charset=UTF-8");
		response.setCharacterEncoding("UTF-8");
		String zh = request.getParameter("zh");
		String mm = request.getParameter("mm");
		IDao dao = new Dao();
		String msg = dao.isLogin(zh, mm);
		Map<String, Object> map = new HashMap<String, Object>();
		map.put("msg", msg);
		ObjectMapper mapper = new ObjectMapper();
		mapper.writeValue(response.getWriter(), map);
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {
		doGet(request, response);
	}

}
